﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Rhino.Mocks;
using System.Web.Mvc;

namespace Rarous.Gryphoon.Spec {
  public static class MvcMockHelpers {
    public static IHttpContext DynamicIHttpContext(this MockRepository mockery) {
      IHttpContext context = mockery.DynamicMock<IHttpContext>();
      IHttpRequest request = mockery.DynamicMock<IHttpRequest>();
      IHttpResponse response = mockery.DynamicMock<IHttpResponse>();
      IHttpSessionState session = mockery.DynamicMock<IHttpSessionState>();
      IHttpServerUtility server = mockery.DynamicMock<IHttpServerUtility>();

      SetupResult.For(context.Request).Return(request);
      SetupResult.For(context.Response).Return(response);
      SetupResult.For(context.Session).Return(session);
      SetupResult.For(context.Server).Return(server);

      mockery.Replay(context);
      return context;
    }

    public static void SetFakeHttpMethod(this IHttpRequest request, string httpMethod) {
      SetupResult.For(request.HttpMethod).Return(httpMethod);
    } 
  }
}